package com.qitmiaojie.controller.health;

import cn.hutool.log.Log;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qitmiaojie.controller.utils.Result;
import com.qitmiaojie.pojo.Health;
import com.qitmiaojie.service.HealthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author miaojie
 * @version 1.0
 * @description 健康驿站接口
 * @date 2023/3/9 21:48
 */
@RestController
@Slf4j
public class HealthController {

    @Autowired
    private HealthService healthService;
    /**
    * @description 上报异常
    * @param health
    * @return
    * @author
    * @date
    */
    @PostMapping("/api/health")
    public Result addHealth(@RequestBody Health health){
        log.info(health.toString());
        return healthService.addHealth(health);
    }
    /***
    * @description 根据userid获取上报信息
    *
    * @return
    * @author
    * @date
    */
    @GetMapping("/api/health")
    public Result getPageById(){
        return healthService.findPageById();
    }
    /***
    * @description 根据id查询
    * @param id
    * @return
    * @author
    * @date
    */
    @GetMapping("/api/health/{id}")
    public Result getById(@PathVariable String id){
        return Result.success("已返回该信息，请返回修改！",healthService.getById(id));
    }
    /***
    * @description 获取近一周确诊人数 疑似人数 等 返回给可视化图表
    * @param
    * @return
    * @author
    * @date
    */
    @GetMapping("/api/health/sourceData")
    public Result sourceData(){
        return healthService.getSourceData();
    }
    /***
    * @description 获取一年所有的确诊情况,每月
    *
    * @return
    * @author
    * @date
    */
    @GetMapping("/api/health/sourceDataTotal")
    public Result sourceDataTotal(){
        return healthService.getSourceDataTotal();
    }
    /***
    * @description 分页查询
    * @param currentPage
    * @return
    * @author
    * @date
    */
    @GetMapping("/api/health/list/{currentPage}")
    public Result list(@PathVariable Integer currentPage){
        return healthService.listByPage(currentPage);
    }

    @PutMapping("/api/health/recovery/{id}")
    public Result editRecovery(@PathVariable String id){
        return healthService.editRecovery(id);
    }
}
